package com.hlbspringcloud.contentcenter.feignclient.fallbackfactory;

import com.hlbspringcloud.contentcenter.domain.dto.uer.UserDTO;
import com.hlbspringcloud.contentcenter.feignclient.UserCenterFeignClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @PROJECT_NAME: spring-cloud-alibaba
 * @CLASS_NAME:
 * @Author: huanglibin
 * @Date: 2020-06-03 22:07
 * @Version: 1.0
 */
@Component
@Slf4j
public class UserCenterFeignClientFallbackFactory implements FallbackFactory<UserCenterFeignClient> {
    @Override
    public UserCenterFeignClient create(Throwable throwable) {
        return new UserCenterFeignClient() {
            @Override
            public UserDTO findById(Integer id) {
                log.warn("远程调用被限流或者降级了",throwable);
                UserDTO userDTO = new UserDTO();
                userDTO.setWxNickname("匿名用户");
                return userDTO;
            }
        };
    }
}
